<%--
  Created by IntelliJ IDEA.
  User: Aaking-aline
  Date: 2022-05-10
  Time: 8:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>登录页面</title>
  </head>
  <body>

    <%
      Object fail = request.getAttribute("fail");
      if(fail != null){
        out.print("<script>alert('登录失败,账号或密码错误')</script>");
      }

    %>

    <center>
      <form action="LoginServlet" method="post" id="form1">
        欢迎登录手机商品管理系统 <br>
        登录账号: <input type="text" name="username" id="username"> <br>
        登录密码: <input type="password" name="password" id="password"> <br>
        <input type="button" value="登录" onclick="login()">
      </form>

      <a href="register.jsp">还没有账号?点我注册呦!</a>

    </center>
  </body>

  <script>
    function login(){
      let username = document.getElementById("username");

      if(username.value.length <= 0){
        alert("账号不能为空!");
        return ;
      }

      let password = document.getElementById("password");

      if(password.value.length < 4){
        alert("密码不能低于4位!");
        return ;
      }

      document.getElementById("form1").submit();

    }
  </script>

</html>
